import React from 'react'
import { Outlet, useNavigate } from 'react-router-dom'

export default function Home() {
    /* 
  navigate方法：
    - 参数1：是to的地址
    - 参数2：配置对象，可以写一个state属性，就是state传参
  
  */
 const navigate = useNavigate()

  const toMusicHandle = ()=>{
    navigate("/main/home/Music/001/?user=cz",{
      state:[
        { id: "001", name: "最伟大的作品" },
        { id: "002", name: "夜曲" },
        { id: "003", name: "爷爷泡的茶" },
        { id: "004", name: "求佛" },
        { id: "005", name: "白狐" }
      ]
    })
  }

  const toNewsHandle =()=>{
    navigate("/main/home/News/001/?user=cz",{
      state:[
        { id: "001", name: "武汉一楼盘停工 业主抱团停贷" },
        { id: "002", name: "空间站国旗与地球同框" },
        { id: "003", name: "对村镇银行客户本金先行垫付" },
      ]
    })
  }  

  return (
    <div>
        <h2>我是Home的内容</h2>
        <button onClick={toMusicHandle}>Music</button>
       <button onClick={toNewsHandle}>News</button>
       <Outlet />
    </div>
  )
}